#include <iostream>
#include <cstring>
using namespace std;
using PII = pair<int ,int>;
#define x first
#define y second
// #define ONLINE_GUDGE
// #define DEBUG
const int N = 21, M = N*N;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = { 0, 0, 1, -1}; 

int n, m;
int ans = 0;
bool st[N][N];
string mp[N];

void dfs(PII start)
{
    st[start.x][start.y] = true;
    ans++;

    for(int k = 0; k < 4; k++)
    {
        int nx = start.x + dx[k], ny = start.y + dy[k];
        if(nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
        if(st[nx][ny] || mp[nx][ny] == '#') continue;

        dfs(make_pair(nx, ny));
    }
}

int main()
{
    #ifdef ONLINE_GUDGE

    #else
    freopen("./in.txt", "r", stdin);
    #endif
    ios::sync_with_stdio(false);   
	cin.tie(0);

    while(cin >> m >> n, m && n)
    {
        memset(st, 0, sizeof st);
        ans = 0;

        PII start;

        for(int i = 0; i < n; i++)
        {
            cin >> mp[i];
            for(int j = 0; j < m; j++)
                if(mp[i][j] == '@')
                {start.x = i, start.y = j;}
        }
        

        dfs(start);

        #ifdef DEBUG
        printf("--------------mp-----------------------\n  ");
        for(int i = 0; i < m; i++)
            printf("%d ", i);
        printf("\n");
        for(int i = 0; i < n; i++)
        {
            printf("%d ", i);
            for(int j = 0; j < m; j++)
            {
                printf("%c ", mp[i][j]);
            }
            printf("\n");
        }
        printf("---------------------------------------\n");

        cout << "start:" << start.x << ' ' << start.y << endl;

        printf("--------------st-----------------------\n  ");
        for(int i = 0; i < m; i++)
            printf("%d ", i);
        printf("\n");
        for(int i = 0; i < n; i++)
        {
            printf("%d ", i);
            for(int j = 0; j < m; j++)
            {
                printf("%d ", st[i][j] ? 1 : 0);
            }
            printf("\n");
        }
        printf("---------------------------------------\n");
        #endif

        cout << ans << endl;

    }
    
}
